<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<div id="app">
    <p>{{fullName}}</p>
</div>

<script src="../js/vue.js"></script>
<script>
    var vm = new Vue({
        el: '#app',
        data: {
            firstname: 'Jiaxiong',
            lastname: 'Ding'
        },
        computed: {
            //计算属性默认只有getter，不过你也可以提供一个setter
            fullName: {
                get: function (){
                    return this.lastname + ' ' + this.firstname
                },
                set: function (newValue){
                    var names = newValue.split(' ')
                    this.lastname = names[0]
                    this.firstname = names[names.length - 1]
                }
            }
        }
    })
</script>
</body>
</html>